#include<iostream>
using namespace std;
int main(){
	int n;
	int i,j,k;
	cout<<" How many integers are to be sorted?\n n=";
	cin>>n;
	int *a = new int [n];//开辟动态内存
	for(i=0;i<n;i++){
		cout<<" a["<<i<<"]="; cin>>a[i];
	}
	for(i=n-1;i>=1;i--){
		for(j=0;j<i;j++){ // 将 a[0] ~ a[i] 中的最大值，放到第 i+1 个位置 
			if(a[j]>a[j+1]){
				k=a[j]; // 交换 a[j] 和 a[j+1]
				a[j]=a[j+1];
				a[j+1]=k;
			}
		}
	}
	cout<<" The "<<n<<" numbers after sorting: "<<endl;
	for(i=0;i<n;i++){
		cout<<a[i]<<",";
	}
	cout<<endl;
	delete [] a;//释放动态内存
	return 0;
}
